package com.wbu.estatemanagement.service.impl;

import com.wbu.estatemanagement.dao.PetMapper;
import com.wbu.estatemanagement.domain.Pet;
import com.wbu.estatemanagement.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PetServiceImpl implements PetService {
    @Autowired
    PetMapper petMapper;

    @Override
    public Pet findPet(Integer userId) {

        List<Pet> pets = petMapper.selectAll();
        Integer petId=0;
        for(Pet pet:pets){
            if (pet.getOwnerId()==userId){
                petId=pet.getId();
            }
        }
        Pet pet = petMapper.selectByPrimaryKey(petId);
        return pet;
    }
}
